package org.example.springkafka.Producer;

import org.example.springkafka.POJO.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

@Component
public class KafkaProducer1 {
    @Autowired
    private KafkaTemplate<String, User> kafkaTemplate;

    public void sendUser(){
        for (int i = 0; i < 10; i++) {
            User user = new User((long)i, "user" + i,i%2);
            kafkaTemplate.send("user", Integer.toString(i), user);
        }
    }
}
